﻿<UserControl x:Class="MomentumPlugin.Common.StrategyControl"
			 x:ClassModifier="internal"
			 
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:Converters="clr-namespace:Utils.Wpf.Converters;assembly=Utils"
			 xmlns:Momentum="clr-namespace:MomentumPlugin.Common" xmlns:System="clr-namespace:System;assembly=mscorlib"

             mc:Ignorable="d"
			 
             Background="#1F1F1F"

             d:DesignHeight="130" 
             d:DataContext="{d:DesignInstance Type=Momentum:StrategyControlVM}" >

	<UserControl.Resources>
		<ResourceDictionary>
			<Converters:EnumToBooleanConverter x:Key="EnumToBooleanConverter" />
			<ObjectDataProvider MethodName="GetValues" ObjectType="{x:Type System:Enum}" x:Key="ExitMode">
				<ObjectDataProvider.MethodParameters>
					<x:Type TypeName="Momentum:ExitMode" />
				</ObjectDataProvider.MethodParameters>
			</ObjectDataProvider>
			<Converters:MultiplierConverter x:Key="MultiplierConverter" />
			<ResourceDictionary.MergedDictionaries>
				<ResourceDictionary Source="pack://application:,,,/Plugins;component/PluginTheme.xaml" />
			</ResourceDictionary.MergedDictionaries>
		</ResourceDictionary>
	</UserControl.Resources>
	<Grid>
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="Auto" />
			<ColumnDefinition Width="Auto" />
			<ColumnDefinition Width="Auto" />
			<ColumnDefinition Width="Auto" />
			<ColumnDefinition Width="Auto" />
			<ColumnDefinition Width="Auto" />
			<ColumnDefinition Width="*" />
			
		</Grid.ColumnDefinitions>
		<Grid.RowDefinitions>
			<RowDefinition Height="*" />
			<RowDefinition Height="*" />
			<RowDefinition Height="*" />
			<RowDefinition Height="*" />
			<RowDefinition Height="*" />
		</Grid.RowDefinitions>

		<!-- Header -->
		<TextBlock Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="4" Text="Execution Parameters" HorizontalAlignment="Center" VerticalAlignment="Center" x:Name="Header" Margin="6" />
		
		<!-- Entry settings -->
		<TextBlock Grid.Row="1" Grid.Column="0" Margin="3,3,6,3" Text="Min. Variation" />
		<TextBox Grid.Row="1" Grid.Column="1" Margin="0,1,0,1" HorizontalContentAlignment="Right" Text="{Binding MinVariation, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, NotifyOnValidationError=True, UpdateSourceTrigger=PropertyChanged}" Width="{Binding ActualWidth, ElementName=Header, Converter={StaticResource MultiplierConverter}, ConverterParameter=0.4}" >
			<TextBox.ToolTip>
				<StackPanel>
					<TextBlock Foreground="Black" FontWeight="Bold" Text="Min. Variation" />
					<TextBlock Foreground="Black" Text="The minimum unidirectional variation needed to open an operation." />
				</StackPanel>
			</TextBox.ToolTip>
		</TextBox>

		<TextBlock Grid.Row="2" Grid.Column="0" Margin="3,3,6,3" Text="Max. Seconds" />
		<TextBox Grid.Row="2" Grid.Column="1" Margin="0,1,0,1" HorizontalContentAlignment="Right" Text="{Binding MaxSeconds, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, NotifyOnValidationError=True, UpdateSourceTrigger=PropertyChanged}" Width="{Binding ActualWidth, ElementName=Header, Converter={StaticResource MultiplierConverter}, ConverterParameter=0.4}" >
			<TextBox.ToolTip>
				<StackPanel>
					<TextBlock Foreground="Black" FontWeight="Bold" Text="Max. Seconds" />
					<TextBlock Foreground="Black" Text="The maximum quantity of seconds allowed to achieve the minimum variation." />
				</StackPanel>
			</TextBox.ToolTip>
		</TextBox>
		<TextBlock Grid.Row="2" Grid.Column="2" Margin="3,3,6,3" Text="seg" />

		<!-- Volume -->
		<TextBlock Grid.Row="3" Grid.Column="0" Margin="3,3,6,3" Text="Volume" />
		<TextBox Grid.Row="3" Grid.Column="1" Margin="0,1,0,1" HorizontalContentAlignment="Right" Text="{Binding Volume, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, NotifyOnValidationError=True, UpdateSourceTrigger=PropertyChanged}" Width="{Binding ActualWidth, ElementName=Header, Converter={StaticResource MultiplierConverter}, ConverterParameter=0.4}" >
			<TextBox.ToolTip>
				<StackPanel>
					<TextBlock Foreground="Black" FontWeight="Bold" Text="Volume" />
					<TextBlock Foreground="Black" Text="The volume to be bought or sold at each operation." />
				</StackPanel>
			</TextBox.ToolTip>
		</TextBox>
		
		<!-- Internal Separator -->
		<Border Grid.Row="1" Grid.Column="3" Grid.RowSpan="4" BorderBrush="{StaticResource SelectedRowBrush}" Background="{StaticResource SelectedRowBrush}" BorderThickness="1" Margin="10,0,10,0" />
		
		<!-- Exit settings -->
		<TextBlock Grid.Row="1" Grid.Column="4" Margin="3,3,6,3" Text="Exit Mode" />
		<ComboBox Grid.Row="1" Grid.Column="5" Grid.ColumnSpan="2" ItemsSource="{Binding Source={StaticResource ExitMode}}" SelectedItem="{Binding ExitMode, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, NotifyOnValidationError=True}" Width="{Binding ActualWidth, ElementName=Header, Converter={StaticResource MultiplierConverter}, ConverterParameter=1}" >
			<ComboBox.Resources>
				<Style TargetType="TextBlock">
					<Style.Triggers>
						<Trigger Property="IsEnabled" Value="True">
							<Setter Property="Foreground" Value="Black" />
						</Trigger>
					</Style.Triggers>
				</Style>
			</ComboBox.Resources>
		</ComboBox>

		<TextBlock Grid.Row="2" Grid.Column="4" Margin="3,3,6,3" Text="Min. Win" />
		<TextBox Grid.Row="2" Grid.Column="5" Margin="0,1,0,1" HorizontalContentAlignment="Right" Text="{Binding MinWin, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, NotifyOnValidationError=True, UpdateSourceTrigger=PropertyChanged}" Width="{Binding ActualWidth, ElementName=Header, Converter={StaticResource MultiplierConverter}, ConverterParameter=0.4}" IsEnabled="{Binding ExitMode, Converter={StaticResource EnumToBooleanConverter}, ConverterParameter=OnFixedAmount}" >
			<TextBox.ToolTip>
				<StackPanel>
					<TextBlock Foreground="Black" FontWeight="Bold" Text="Min. Win" />
					<TextBlock Foreground="Black" Text="The minimum win before exiting the operation." />
				</StackPanel>
			</TextBox.ToolTip>
		</TextBox>

		<TextBlock Grid.Row="3" Grid.Column="4" Margin="3,3,6,3" Text="Max. Loss" />
		<TextBox Grid.Row="3" Grid.Column="5" Margin="0,1,0,1" HorizontalContentAlignment="Right" Text="{Binding MaxLoss, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, NotifyOnValidationError=True, UpdateSourceTrigger=PropertyChanged}" Width="{Binding ActualWidth, ElementName=Header, Converter={StaticResource MultiplierConverter}, ConverterParameter=0.4}" IsEnabled="{Binding ExitMode, Converter={StaticResource EnumToBooleanConverter}, ConverterParameter=OnFixedAmount}" >
			<TextBox.ToolTip>
				<StackPanel>
					<TextBlock Foreground="Black" FontWeight="Bold" Text="Max. Loss" />
					<TextBlock Foreground="Black" Text="The maximum loss before exiting the operation." />
				</StackPanel>
			</TextBox.ToolTip>
		</TextBox>

	</Grid>
</UserControl>